package cn._2dland.gae.httpclient.method;

import java.util.Iterator;
import java.util.Map.Entry;

public class GetMethod extends HttpMethod {
	public GetMethod(String url) {
		super(url);
	}

	public String getMethodName() {
		return "GET";
	}

	public String getURL() {
		StringBuffer urlBuf = new StringBuffer(url);
		if(parameters != null) {
			urlBuf.append(url.indexOf("?")<0 ? "?" : "&");
			Iterator<Entry<String, String>> ps = parameters.entrySet().iterator();
			while(ps.hasNext()) {
				Entry<String, String> p = ps.next();
				urlBuf.append(p.getKey()).append("=").append(p.getValue()).append("&");
			}
			if(urlBuf.charAt(urlBuf.length()-1) == '&')
				urlBuf = urlBuf.deleteCharAt(urlBuf.length()-1);
		}
		return urlBuf.toString();
	}
}
